package com.siwei.mes.entity.erp;

import com.siwei.mes.common.util.JsonUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;

/**
 * ERP合同扩展信息
 *
 * @Description: ERP合同扩展信息
 * @Version: 1.0
 * @author: mlchen
 * @date: 2024/9/24 19:59
 */
@Data
public class ContractExtraInfo {
    private LimitinfoBean limitinfo;
    @ApiModelProperty(value = "合同名称")
    private String contractName;

    @Data
    public static class LimitinfoBean {
        private int limitType;
        private String limitDate;
        private String creditQuantity;
        private Object creditQuantityDate;
    }

    /**
     * 字符串转实体
     *
     * @param str
     * @return
     */
    public static ContractExtraInfo jsonToObj(String str) {
        if (StringUtils.isBlank(str)) {
            return null;
        }
        boolean jsonString = JsonUtils.isJSONString(str);
        if (!jsonString) {
            return null;
        }
        String info = StringEscapeUtils.unescapeJava(str);
        return JsonUtils.getObject(info, ContractExtraInfo.class);
    }
}
